package groovy
class Handle{
    def f1(){println("f1 handler")}
    def f2(){println("f2 handler")}

}
class Example{
    def f1(){println("f1 example")}
    def f2(){println("f2 example")}
    def foo(clouser){
        //println("this "+ clouser.delegate)
        clouser.delegate=new Example()
        clouser()
    }
}
def f1(){println("f1 script")}
new Example().foo{
    f1()
    f2()
}

